<html>
<head>
<script type="text/javascript" src="../../src/gew.js"></script>


<script type="text/javascript">
var testScreenIdx=0;
var elapseMls = 0;
var frameCount = 0;
function MyScreen(game)
{
    gewScreen.call(this,game);
    this.scene2d = new gewScene2D(this.game);
    this.onTick = function(mls)
    {
        /*var gl = this.game.gl;
        var tmanager = this.game.textureManager;
        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
        this.scene2d.render();
        elapseMls+=mls;
        frameCount++;
        if(elapseMls>=2000)
        {
            var fps = frameCount/2;
            document.getElementById("fps").innerHTML="Frame Rate:"+fps;
            elapseMls = 0;
            frameCount = 0;
        }*/
		
		var currTime = (new Date()).getTime();
		var m1 = gewMat4.getRotate(new gewVec3(5,2,1),2);
		var m2 = gewMat4.getRotate(new gewVec3(1,2,1),2);
		for(var i=0;i<10000;i++)
		{
		  var m3 = m1.mul(m2);
		}
		var delta = (new Date()).getTime()-currTime;
		console.log("\nDELTA:"+delta);
		
		/*
		var currTime = (new Date()).getTime();
		var m1 = Matrix.Rotation(2,Vector.create([5,2,1]));
		var m2 = Matrix.Rotation(2,Vector.create([1,2,1]));
		for(var i=0;i<10000;i++)
		{
		  var m3 = m1.multiply(m2);
		}
		var delta = (new Date()).getTime()-currTime;
		console.log("\nDELTA:"+delta);
		*/
		
    }
    this.init = function()
    {
	var gl = this.game.gl;
        //gl.activeTexture(gl.TEXTURE0);
        //Load texture
        var manager = this.game.textureManager;
        manager.loadTexture("atlat0","Resource/atlas0.png");
        manager.loadTexture("atlat1","Resource/atlas1.png");
        var mainTexList = [];
        mainTexList[0] = manager.textureList['atlat0'];
        mainTexList[1] = manager.textureList['atlat1'];
        manager.loadTextureAtlas("test","Resource/atlas.tai",mainTexList);
        var atlas = manager.textureAtlasList.test;
        this.scene2d.atlas = atlas;
        var rec = new gewSprite2D(this.game);
        rec.setAsRectangle(0,0,100,100)
        rec.setSubTexture("Officer_SwatVan.png");
        this.scene2d.layer0.insert(rec);
    }
    this.isDrag = false;
    this.onMouseDown = function(e)
    {
        this.isDrag = true;
    }
    this.onMouseMove = function(e)
    {
        if( this.isDrag)
            console.log("move move");
    }
    this.onMouseUp = function(e)
    {
        this.isDrag = false;
    }
}
function main()
{
    var game = new gewGame("cavans_id");
    var blackScreen = new MyScreen(game);
    game.addScreen(blackScreen,testScreenIdx);
    game.setScreen(testScreenIdx);
    blackScreen.init();
    setInterval(function(){game.run()},1);
}
</script>
</head>
<body onload="main()">
  <div style="text-align: center">
    <!-- this is the canvas that we render to -->
    <canvas id="cavans_id" width="640" height="480"></canvas>

    <!-- a convenient div to use to display log messages -->
    <div id="fps"></div>
    <a>Dont see anything? Get FireFox 3.7 and enable webGL feature ( about:config >> set webGL.. param to true )</a>
</body>
</html>